// 回文链表
/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {boolean}
 */
 var isPalindrome = function(head) {
    const ans=[];let i;
    while(head!=null){
        ans.push(head.val);
        head=head.next;
    }
    /*let n=ans.length-1;
    let m=Math.floor(ans.length/2);
    for(i=0;i<m;i++){
        if(ans[i]!==ans[n-i])
         return false;
        }
  return true;*/
  return ans.join('')==ans.reverse().join('')
  };